<div class="layui-fluid layui-anim website-anim-up" id="website-class-solicit-update" lay-title="选题修改">
    <div class="layui-row layui-col-space8 website-container">
        <div class="layui-col-md10 layui-col-sm10 layui-col-xs10">
            <form class="layui-form" id="class-solicit-update-form">
                <div class="layui-card" id="client-user-info">
                    <div class="layui-card-header">基本信息</div>
                    <div class="layui-card-body layui-form-item">
                        <div class="layui-row">
                            <!-- 基本信息-->
                            <div class="layui-form-item website-hide">
                                <label class="layui-form-label">id：</label>
                                <div class="layui-input-block">
                                    <input type="text" name="selectId" data-th-value="${result.selectId}">
                                </div>
                            </div>
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label website-form-item-require">征集公告名称</label>
                                <div class="layui-input-block">
                                    <select name="noticeId" lay-verify="required"
                                            lay-filter="noticeId">
                                        <option value="">请选择</option>
                                        <option
                                                th:each="item : ${noticeList}"
                                                th:value="${item.noticeId}" th:text="${item.title}">
                                        </option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6">
                                <label class="layui-form-label website-form-item-require">建议课题名称</label>
                                <div class="layui-input-block">
                                    <input type="text" name="topicName" lay-verify="required" maxlength="50" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-row">
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label website-form-item-require">学科分类</label>
                                <div class="layui-input-block">
                                    <select name="subjectTypeCodes"
                                            lay-verify="required"
                                            xm-select-direction="down"
                                            xm-select="subjectTypeCodes"
                                            xm-select-skin="default">
                                        <option value="">请选择</option>
                                        <option
                                                th:each="item : ${subjectTypeCode}"
                                                th:value="${item.code}" th:text="${item.name}">
                                        </option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-row">
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label website-form-item-require">建议人姓名</label>
                                <div class="layui-input-block">
                                    <input type="text" name="userName"lay-verify="required" maxlength="50" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label website-form-item-require">建议单位</label>
                                <div class="layui-input-block">
                                    <input type="text" name="unitName" lay-verify="required" maxlength="50" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-row">
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label layui-form-label">行政职务</label>
                                <div class="layui-input-block">
                                    <select name="position" lay-filter="positionTypeCode">
                                        <option value="">请选择</option>
                                        <option
                                                th:each="item : ${positionTypeCode}"
                                                th:value="${item.code}" th:text="${item.name}">
                                        </option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6">
                                <label class="layui-form-label layui-form-label">职称级别</label>
                                <div class="layui-input-block">
                                    <select name="academic" lay-filter="titleTypeCode">
                                        <option value="">请选择</option>
                                        <option
                                                th:each="item : ${titleTypeCode}"
                                                th:value="${item.code}" th:text="${item.name}">
                                        </option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-row">
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label website-form-item-require">职称</label>
                                <div class="layui-input-block">
                                    <input type="text" name="professionCode" lay-verify="required" autocomplete="off"
                                           maxlength="50" class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-row">
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label website-form-item-require">手机</label>
                                <div class="layui-input-block">
                                    <input type="text" name="mobile" lay-verify="required|phone"  maxlength="50" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline layui-col-xs6 layui-col-sm6 layui-col-md6 ">
                                <label class="layui-form-label layui-form-label">座机</label>
                                <div class="layui-input-block">
                                    <input type="text" name="phone" lay-verify="tellphone"  maxlength="50"  autocomplete="off" class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-row">
                            <div class="layui-inline layui-col-xs12 layui-col-sm12 layui-col-md12">
                                <label class="layui-form-label website-form-item-require">建议立项依据摘要</label>
                                <div class="layui-input-block">
                                <textarea class="layui-textarea" lay-verify="required"  maxlength="500" name="proveContent" placeholder="请输入内容，限制 500 字"
                                          autocomplete="off"></textarea>
                                </div>
                            </div>
                        </div>
                        <div class="layui-card-footer">
                            <button class="layui-btn" lay-submit="" lay-filter="class-solicit-update-submit" id="submit">保存</button>
                            <button class="layui-btn layui-btn-warm" id="clean">取消</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<script data-th-inline="javascript" type="text/javascript">
    layui.use(['dropdown', 'jquery', 'laydate', 'form', 'website', 'formSelects', 'validate'], function () {
        let $ = layui.jquery,
            laydate = layui.laydate,
            website = layui.website,
            form = layui.form,
            formSelects = layui.formSelects,
            validate = layui.validate,
            view = layui.view,

            result = [[${result}]],
            $form = $('#class-solicit-update-form'),
            $view = $('#website-class-solicit-update'),
            $submit = $('#submit'),
            $clean = $view.find('#clean');
        // 重新渲染 form否则不会显示下拉框
        form.render();
        formSelects.render();

        initExpertValue()
        form.verify(validate);


        form.on('submit(class-solicit-update-submit)', function () {
            let params = $form.serializeJson();
            website.post(ctx + 'topicSelect/update', params, function () {
                //  update 关闭当前页面
                $('#website-home').find('#query').click();
                let currentUrl = window.location.hash.replace('#', '');
                website.view.tab.del(currentUrl);
                window.location.reload();
            });
            return false;
        })


        function initExpertValue() {
            const formName ='class-solicit-update-form-'+result.selectId
            $('#class-solicit-update-form')[0].setAttribute('lay-filter',formName);
            form.val(formName, {
                "selectId": result.selectId,
                "noticeId": result.noticeId,
                "topicName": result.topicName,
                "userName": result.userName,
                "unitName": result.unitName,
                "position": result.position,
                "academic": result.academic,
                "phone": result.phone,
                "mobile": result.mobile,
                "professionCode": result.professionCode,
                "proveContent": result.proveContent
            });
            formSelects.value('subjectTypeCodes', result.subjectTypeCodes);
        }

        $clean.on('click', function () {
            let currentUrl = window.location.hash.replace('#', '');
            website.view.tab.del(currentUrl);
            window.location.reload();
        })
    })


</script>